PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Repeat (forever)

The Repeat (forever) form of the Repeat statement is an infinite loop --a Repeat statement that does not specify when the repetition stops. The only way to exit the loop is by using an Exit statement. For more information, see Exit.

SYNTAX
repeat
    [ statement ]...
end [ repeat ]

where

statement is any AppleScript statement.

EXAMPLE

The following example prints each open AppleWorks document, then closes the document window. It uses an Exit statement to exit the loop.

tell application "AppleWorks"
    set numberOfDocuments to (count documents)
    set i to 1
    repeat
        if i > numberOfDocuments then
            exit repeat
        end if
        print front document without one copy -- display Print dialog
        close front document saving ask -- ask before saving modified doc
        set i to i + 1
    end repeat
end tell

The phrase without one copy tells an AppleWorks document to display the Print dialog before printing.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)